#pragma once
#include "Sock.h"
#include "Theadlib/thread.h"
#include "snetwork/NluConnection.h"
#include "snetwork/NluHttpRequest.h"

class  SNETWORK_API Sock::CNluHttpCreate 
{
public:
    static CNluHttpCreate *instance();
    void parseGetArr(void *param);
    long getfilesize(FILE *stream);
    void findClassMap( nl_http_request_t *r );
    std::string get_mime_type( const char * namech, int len );

    int _not_found();
    int _call_method(ClassMap::iterator itf, nl_http_request_t *r);
    void _showclient();
    int mkstemp (char *tmpl);
    void normal_headers( int status, std::string mime_type );
    bool http_headers( int status, std::string mime_type, long int u_len, bool is_gzip);
    bool http_headers( int status, std::string mime_type, long int u_len, bool is_gzip, const char *path);
    void set_cookie(std::string &header);
        	
	int pre_data(std::string mine_type, bool is_gzip, nl_http_request_t *r);
	ssize_t send_data(std::string mine_type, nl_http_request_t *r);
    
    int execute(void *parr, nl_http_request_t *r);
    bool SocketConnected(int sock);
    long SendStaticFile(const char *sends, long len);
protected:
    DBConfig *m_dbconfig;
	paramArr *m_par;
	int m_sockfd;
	http_chain_t *m_q;
	std::string m_filename;
	
private: 
    static CNluHttpCreate* m_instance;
    CNluHttpCreate();    
    class CGarbo {public: ~CGarbo(){if (CNluHttpCreate::m_instance) delete CNluHttpCreate::m_instance;}};
    static CGarbo Garbo;	
};
